<?php

class BizcardHelper
{

    static function generatePassword ($length = 6)
    {
        $chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
        $count = mb_strlen($chars);
        
        for ($i = 0, $result = ''; $i < $length; $i ++) {
            $index = rand(0, $count - 1);
            $result .= mb_substr($chars, $index, 1);
        }
        return $result;
    }

    public static function isCorrectPcMailAddress ($email)
    {
        if (preg_match("/^[\w\.\-\+]+?@([\w-]+\.)+[a-zA-Z]{2,4}$/", $email)) {
            return TRUE;
        }
        return FALSE;
    }

    public static function madeNameFontPdf ($filename)
    {
        $str = str_replace(" ", "_", strtolower($filename));
        $str = str_replace(".", "_", strtolower($str));
        $str = str_replace("-", "_", strtolower($str));
        $str = str_replace("+", "_", strtolower($str));
        return strtolower($str);
    }
}